﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using SFOOD.Model;

namespace SFOOD.Controllers
{
    public class HomeController
    {
        public static async Task<FoodListModel> GetList()
        {
            using (var client = new HttpClient())
            {
                var uri = new Uri("http://123.30.174.73:8016/food/getFoodByCategory");
                var respon = client.GetAsync(uri).Result;
                if (respon.IsSuccessStatusCode)
                {
                    var data = respon.Content.ReadAsStringAsync().Result;
                    var prodt = JsonConvert.DeserializeObject<FoodListModel>(data);
                    return prodt;
                }
                return null;
            }
        }

    }
}
